<template>
  <div id="main_text" :style="{ width: '580px', height: '370px'}" ></div>
</template>

<script setup>
import {onMounted} from "vue";
import * as echarts from 'echarts';
onMounted(()=>{
  let chartDom = document.getElementById('main_text');
  let myChart = echarts.init(chartDom);
  let option;

  option = {
    title: {
      text: '生猪数量占比',
      top: '5%',
      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      top: '90%',
      left: 'center'
    },
    series: [
      {
        name: '生猪数量',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2
        },
        label: {
          show: false,
          position: 'center'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: '40',
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        data: [
          { value: 1048, name: 'web' },
          { value: 735, name: 'java' },
          { value: 580, name: 'python' },
          { value: 484, name: 'unity' },
          { value: 300, name: 'go' }
        ]
      }
    ]
  };

  option && myChart.setOption(option);

})
</script>

<style lang="less" scoped>

</style>
